import { createRouter, createWebHistory } from "vue-router";
import Home from "@/views/Home.vue";
import { KeepAlive } from "vue";
// 获取环境变量，Vite 会自动替换这里的值
const base = import.meta.env.VITE_BASE_URL || "/";
const router = createRouter({
  history: createWebHistory(base),
  routes: [
    {
      path: "/",
      redirect: "/home",
    },
    {
      path: "/home",
      name: "Home",
      component: Home,
    },
    {
      path: "/shopping",
      name: "Shopping",
      component: () => import("../views/Shopping.vue"),
    },
    {
      path: "/live",
      name: "Live",
      component: () => import("../views/Live.vue"),
    },
    {
      path: "/my",
      name: "My",
      component: () => import("../views/My.vue"),
    },
    {
      path: "/search",
      name: "Search",
      redirect: { name: "index" },
      children: [
        {
          path: "/",
          name: "index",
          component: () => import("../views/search/Searchindex.vue"),
        },
        {
          path: "list",
          name: "list",
          component: () => import("../views/search/SearchList.vue"),
        },
      ],
      component: () => import("../views/Search.vue"),
    },
    {
      path: "/sort",
      name: "Sort",
      component: () => import("../views/Sort.vue"),
    },
    {
      path: "/detail",
      name: "Detail",
      meta: { KeepAlive: false },
      component: () => import("../views/Detail.vue"),
    },
    {
      path: "/contentList",
      name: "List",
      component: () => import("../views/List.vue"),
    },
    {
      path: "/login",
      name: "Login",
      component: () => import("../views/login/Login.vue"),
    },
    {
      path: "/register",
      name: "Register",
      component: () => import("../views/login/Register.vue"),
    },
    {
      path: "/modify",
      name: "Modify",
      component: () => import("../views/login/modify.vue"),
    },
    {
      path: "/order",
      name: "Order",
      component: () => import("../views/Order.vue"),
    },
    {
      path: "/houtai",
      name: "Houtai",
      component: () => import("../views/Houtai.vue"), 
    }
  ],
});
export default router;
